function [stat] = getStatus(whichBoat)

assert((whichBoat==1) || (whichBoat==2) || (whichBoat == 3), ...
    'Bad boat selection, needs to be 1, 2, or 3.\n');

switch whichBoat
    case 1
        boatIP = '192.168.1.101';
    case 2
        boatIP = '192.168.1.102';
    case 3
        boatIP = '192.168.1.103';
end  
% 
% % username = 'actuv';
% % password = 'CMU-actuv';
% % path = 'boats\ code/New\ Boats\ Code/Outputs/';
% % sftp_simple_get(boatIP, username, password, [path 'status.txt']);

% url = ['http://' boatIP '/status.txt'];
% randSeed = rand(1);
% name = ['status' num2str(randSeed) '.txt'];
% urlwrite(url, name);
% 
% fid = fopen(name);
% statusDump = '';
% statPart = fgets(fid);
% while (statPart ~= -1)
%     statusDump = [statusDump statPart];
%     statPart = fgets(fid);
% end
% fclose(fid);
% delete(name);

statusDump = urlread(['http://' boatIP '/status.txt']);
stat.started = str2double(myParse(statusDump, 'started'));
stat.state = myParse(statusDump, 'state');
stat.compTime = myParse(statusDump, 'compTime');
stat.gpsTime = myParse(statusDump, 'gpsTime');
stat.commandLat =  str2double(myParse(statusDump, 'commandLat'));
stat.commandLon =  str2double(myParse(statusDump, 'commandLon'));
stat.commandPrecision =  str2double(myParse(statusDump, 'commandPrecision'));
stat.commandSpeed =  str2double(myParse(statusDump, 'commandSpeed'));
stat.commandHeading =  str2double(myParse(statusDump, 'commandHeading'));
stat.lat = str2double(myParse(statusDump, 'lat'));
stat.lon = str2double(myParse(statusDump, 'lon'));
stat.compass = str2double(myParse(statusDump, 'compass'));
stat.temp = str2double(myParse(statusDump, 'temp'));
stat.boat = whichBoat; % I may read this from the status file in the future, but should be the same as this
end



function [retString] = myParse(statusDump, tag)
%% parses XML data
%% grabs first substring in statusDump contained within <tag>__data here__</tag> 

retString = statusDump(strfind(statusDump, ['<' tag '>']) + length(['<' tag '>']):strfind(statusDump, ['</' tag '>'])-1);


end